package net.mcreator.makecustomitem.procedure;

import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.common.MinecraftForge;

import net.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;

import net.mcreator.makecustomitem.ElementsMakecustomitemMod;

import java.util.Map;

@ElementsMakecustomitemMod.ModElement.Tag
public class ProcedureAttributeGet2 extends ElementsMakecustomitemMod.ModElement {
	public ProcedureAttributeGet2(ElementsMakecustomitemMod instance) {
		super(instance, 12);
	}

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			System.err.println("Failed to load dependency entity for procedure AttributeGet2!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("ItemSpeed")) == (false)))) {
			entity.getEntityData().setDouble("ItemSpeedSave",
					(((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("ItemSpeedSave"))));
			entity.getEntityData().setBoolean("ItemSpeed", (true));
		} else if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("ItemSpeed")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("ItemSpeedSave"))));
			entity.getEntityData().setBoolean("ItemSpeed", (false));
		}
		if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("ItemSpeed")) == (false)))) {
			entity.getEntityData().setDouble("ItemSpeedSave",
					(((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("ItemSpeedSave"))));
			entity.getEntityData().setBoolean("ItemSpeed", (true));
		} else if ((((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemOffhand() : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("ItemSpeed")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("ItemSpeedSave"))));
			entity.getEntityData().setBoolean("ItemSpeed", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("SpeedBlue1")) == (false)))) {
			entity.getEntityData().setDouble("SpeedNum1",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("SpeedNum1"))));
			entity.getEntityData().setBoolean("SpeedBlue1", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(0) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("SpeedBlue1")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("SpeedNum1"))));
			entity.getEntityData().setBoolean("SpeedBlue1", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("SpeedBlue2")) == (false)))) {
			entity.getEntityData().setDouble("SpeedNum2",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("SpeedNum2"))));
			entity.getEntityData().setBoolean("SpeedBlue2", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(1) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("SpeedBlue2")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("SpeedNum2"))));
			entity.getEntityData().setBoolean("SpeedBlue2", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("SpeedBlue3")) == (false)))) {
			entity.getEntityData().setDouble("SpeedNum3",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("SpeedNum3"))));
			entity.getEntityData().setBoolean("SpeedBlue3", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(2) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("SpeedBlue3")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("SpeedNum3"))));
			entity.getEntityData().setBoolean("SpeedBlue3", (false));
		}
		if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) > 0) && ((entity.getEntityData().getBoolean("SpeedBlue4")) == (false)))) {
			entity.getEntityData().setDouble("SpeedNum4",
					(((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
							? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY)
									.getTagCompound().getDouble("Speed")
							: -1));
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) + (entity.getEntityData().getDouble("SpeedNum4"))));
			entity.getEntityData().setBoolean("SpeedBlue4", (true));
		} else if ((((((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).hasTagCompound()
				? ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).inventory.armorInventory.get(3) : ItemStack.EMPTY).getTagCompound()
						.getDouble("Speed")
				: -1) <= 0) && ((entity.getEntityData().getBoolean("SpeedBlue4")) == (true)))) {
			entity.getEntityData().setDouble("Speed",
					((entity.getEntityData().getDouble("Speed")) - (entity.getEntityData().getDouble("SpeedNum4"))));
			entity.getEntityData().setBoolean("SpeedBlue4", (false));
		}
	}

	@SubscribeEvent
	public void onPlayerTick(TickEvent.PlayerTickEvent event) {
		if (event.phase == TickEvent.Phase.END) {
			Entity entity = event.player;
			World world = entity.world;
			int i = (int) entity.posX;
			int j = (int) entity.posY;
			int k = (int) entity.posZ;
			java.util.HashMap<String, Object> dependencies = new java.util.HashMap<>();
			dependencies.put("x", i);
			dependencies.put("y", j);
			dependencies.put("z", k);
			dependencies.put("world", world);
			dependencies.put("entity", entity);
			dependencies.put("event", event);
			this.executeProcedure(dependencies);
		}
	}

	@Override
	public void preInit(FMLPreInitializationEvent event) {
		MinecraftForge.EVENT_BUS.register(this);
	}
}
